#ifndef __MATERIAL__
#define __MATERIAL__

#include <string>
#include <vector>

//#include "Tracer.h"
//#include "Light.h"
#include "RGBColor.h"
#include "Texture.h"
#include "SolidColor.h"
#include "ImageTexture.h"

class ShadeRec;

namespace Engine
{
	class Light;
	class Tracer;

	enum SURFACE_TYPE
	{
		DIFF,
		REFL,
		GLOSSY,
	};

	class Material
	{
	public:

		Material(SURFACE_TYPE p_type)
		{
			m_type = p_type;
		}

		Material()
		{
			m_type = DIFF;
		}

		Material(Texture* p_currentTexture)
		{
			m_type = DIFF;
			m_materialTexture = p_currentTexture;
			m_containsTexture = p_currentTexture->ContainsTexture();
		}

		virtual RGBColor Shade(ShadeRec& sr, std::vector<Light*>& sceneLights, Tracer* p_tracerPtr, Light* ambient = NULL) = 0;

		RGBColor Getcolor()
		{
			float x = 0, y = 0;
			return m_materialTexture->GetColor(x, y);
		}

		RGBColor GetColor(float& p_x, float& p_y)
		{
			return m_materialTexture->GetColor(p_x, p_y);
		}

		void SetColor(RGBColor p_cD)
		{
			m_materialTexture = new SolidColor(p_cD);
		}

		void SetTexture(RGBColor& p_color)
		{
			m_materialTexture = new SolidColor(p_color);
		}

		void SetTexture(string& p_path)
		{
			m_materialTexture = new ImageTexture(p_path);
		}

		SURFACE_TYPE GetType()
		{
			return m_type;
		}

		void SetType(SURFACE_TYPE p_type)
		{
			m_type = p_type;
		}

		float GetReflectionConstant()
		{
			return m_Kr;
		}
		void SetReflectionConstant(float p_Kr)
		{
			m_Kr = p_Kr;
		}

		std::string GetMaterialName()
		{
			return m_materialName;
		}

		void SetTexture(Texture* p_texture)
		{
			m_materialTexture = p_texture;
		}

		void SetMaterialName(std::string& p_materialName)
		{
			m_materialName = p_materialName;
		}

	protected:
		Texture* m_materialTexture;
		bool m_containsTexture;
		SURFACE_TYPE m_type;
		float m_Kr;
		std::string m_materialName;
	};
}

#endif // !__MATERIAL_
